package com.sptpc.demo1.service.impl;

import com.sptpc.demo1.model.Student;
import com.sptpc.demo1.repository.StudentRepository;
import com.sptpc.demo1.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentjpaService implements IStudentService {
    @Autowired
    private  StudentRepository studentRepository;
    @Override
    public void addNewStudent(Student student) {
        studentRepository.save(student);
    }

    @Override
    public List<Student> getAllDrinks() {
        return studentRepository.findAll();
    }

    @Override
    public void delStudent(Long id) {
        studentRepository.deleteById(id);
    }

    @Override
    public Student getStudentById(Long id) {
        return studentRepository.findById(id).orElse(null);
    }

    @Override
    public void updateDrink(Student student) {
        studentRepository.save(student);
    }

}
